package cn.wolfcode.wolf2w.redis.test;

import cn.wolfcode.wolf2w.util.Consts;

/**
 * 通过枚举类去拼接key
 */
public enum RedisByKey {

    VERIFY_CODE("verify_code",Consts.VERIFY_CODE_VAI_TIME*60),
    USER_TOKEN("user_token",Consts.VERIFY_CODE_VAI_TIME*60),
    STRATEGY_STATIC_VO("strategy_static_vo",-1),
    STRATEGY_USERID_FAVOR("strategy_userid_favor",-1),
    STRATEGY_HUMBUP("strategy_humbup",-1),
    TRAVELS_USERID_FAVOR("strategy_userid_favor",-1),
    TRAVEL_STATIC_VO("travel_static_vo",-1);

    private String prefix;
    private int time;

    private RedisByKey(String prefix, int time){
        this.prefix=prefix;
        this.time=time;
    }

    //拼接key的方法
    public String join(String... codes){
            StringBuilder sb=new StringBuilder();
            sb.append(this.prefix);
            for (String code:codes){
                sb.append(":").append(code);
            }
            return sb.toString();
    }
}
